import threading
import time


def background_task():
    for i in range(5):
        print("Background task is running")
        time.sleep(1)


# 创建一个守护线程
daemon_thread = threading.Thread(target=background_task)
daemon_thread.daemon = True

# 创建一个非守护线程
non_daemon_thread = threading.Thread(target=background_task)

# 启动线程
daemon_thread.start()
non_daemon_thread.start()

# 等待非守护线程完成
non_daemon_thread.join()

print("Main thread is done")
